package cn.edu.shou.lab.config.converters;

import com.google.gson.Gson;
import com.google.gson.JsonObject;

public class BackResult {
    private static final String STATE = "state";
    private static final String MSG = "msg";
    private static final String DATA = "data";
    private boolean state = true;
    private Object data;
    private String msg = "";

    public boolean isState() {
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        JsonObject message = new JsonObject();
        message.addProperty(STATE, this.isState());
        message.addProperty(MSG, this.getMsg());
        message.addProperty(DATA, new Gson().toJson(this.data));
        return message.toString();
    }
}
